<template>
	<div class="ordermanage-allorders">
		<div class="content">
			<div class="tablebox">
				<div class="row box-orderType">
					<div :class="'type '+ (ordertype==1?'select':'')" @click="changeOrderType(1)">全部订单</div>
					<div :class="'type '+ (ordertype==2?'select':'')" @click="changeOrderType(2)">待支付</div>
					<div :class="'type '+ (ordertype==3?'select':'')" @click="changeOrderType(3)">已退款</div>
					<div :class="'type '+ (ordertype==4?'select':'')" @click="changeOrderType(4)">已取消订单</div>
				</div>
				<div class="headcontrolsbox">
					<div class="left" style="width:90%;display:flex;">
						<template v-if="ordertype==1">
							<el-select class="comSearchInput" v-model="headControls.selectObj.select"
								style="width:2rem;margin-right: 0.1rem;"
								clearable collapse-tags  placeholder="全部状态" @change="selectObjChange">
								<el-option
								v-for="item in headControls.selectObj.data"
								:key="item.value"
								:label="item.label"
								:value="item.value">
								</el-option>
							</el-select>
						</template>
						<el-date-picker
							class="datepicker"
							style="margin-right: 0.1rem;"
							v-model="headControls.datePickerValue"
							value-format="yyyy-MM-dd HH:mm:ss"
							type="datetimerange"
							align="right"
							:start-placeholder="searchListParam.startTime"
							:end-placeholder="searchListParam.endTime"
							:default-time="['00:00:00', '23:59:59']"
							@change="datepickerChange">
						</el-date-picker>
						<el-input class="paraminput comSearchInput"  ref="inputKeyWords"
							style="width:4.2rem;margin-right: 0.1rem;"
							placeholder="输入 学员/手机号/班级名称/订单号 查找订单"
							suffix-icon="el-icon-search"
							v-model="headControls.param"
							clearable
							@clear="inputKeyWordsClear"
							@keyup.enter.native="queryBtnClick">
						</el-input>
						<div class="search_btn" v-if="hasApi('orderManage_queryInList')" @click="queryBtnClick">搜索</div>
					</div>
					<div class="right" style="width:10%;">
						<el-button  type="primary" v-if="hasApi('orderManage_export')" style="width: 1rem;height: 0.36rem;padding: 0.1rem 0.2rem;
						border-radius: 0.08rem;font-size:0.16rem;" :disabled="exportstate" @click="exportOrder">导出订单</el-button>
					</div>
				</div>
				<template>
					<!-- 全部订单、待支付订单 -->
					<table v-show="ordertype==1||ordertype==2" class="table coverTable"
					 cellspacing="0" style="width: 100%;">
						<thead class="thead">
							<tr>
								<td>订单号</td>
								<td></td>
								<td>课程/商品/订金</td>
								<td>购买学员</td>
								<td>购买数量/单位</td>
								<td>单价</td>
								<td>总计</td>
								<td>优惠金额</td>
								<td>实际支付</td>
								<td>交易时间</td>
								<td>支付方式</td>
								<td>状态</td>
								<td>操作</td>
							</tr>
						</thead>
						<tbody class="tbody" v-if="moneyTableData&&moneyTableData.length>0">
							<tr v-for="(row,index) in moneyTableData" :key="index"
							 :rowIndex="row.primaryIndex%2===0?'even':'odd'"
							 @mouseenter="tableRowHoverIndex=row.primaryIndex"
							 @mousemove="tableRowHoverIndex=row.primaryIndex"
							 @mouseleave="tableRowHoverIndex=-1"
							 :rowhover="row.primaryIndex==tableRowHoverIndex?'1':'0'">
								<template v-if="row.isCombine">
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.orderNo}}</td>
									<td>
										<div class="orderTypeSymbol" :type="row.ordertype" v-if="row.ordertype==1">课</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==2">商</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==3">订</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==4">餐</div>
									</td>
									<td>{{row.orderName}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.studentName}}</td>
									<td>
										<span v-show="row.buyNumber===0||(row.buyNumber)">
											<!-- {{row.buyNumber+'/'+row.unit}} -->
											<span>{{row.buyNumber+' /'}}</span>
											<span style="font-size:0.14rem;">{{row.unit}}</span>
										</span>
									</td>
									<td >
										<span v-show="row.unitPrice===0||(row.unitPrice)">￥{{row.unitPrice}}</span>
									</td>
									<td >
										<span v-show="row.totalMoney===0||(row.totalMoney)">￥{{row.totalMoney}}</span>
									</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">
										<span v-show="row.discountMoney===0||(row.discountMoney)">￥{{row.discountMoney}}</span>
									</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">
										<span v-show="row.realMoney===0||(row.realMoney)">￥{{row.realMoney}}</span>
									</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.createTime}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.payModeName}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.orderState}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">
										<el-button v-if="row.opratetype!=1" style="font-size:0.16rem;" @click="moneyTableRowClick(row)"
										type="text" size="medium">详情</el-button>
										<el-button v-if="row.opratetype==1 && hasApi('orderManage_payOrder')" style="font-size:0.16rem;" @click="reselectPayMode(row)"
										type="text" size="medium">支付</el-button>
									</td>
								</template>
								<template v-else>
									<td>{{row.orderNo}}</td>
									<td >
										<div class="orderTypeSymbol" :type="row.ordertype" v-if="row.ordertype==1">课</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==2">商</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==3">订</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==4">餐</div>
									</td>
									<td>{{row.orderName}}</td>
									<td>{{row.studentName}}</td>
									<td>
										<span v-show="row.buyNumber===0||(row.buyNumber)">
											<!-- {{row.buyNumber+'/'+row.unit}} -->
											<span>{{row.buyNumber+' /'}}</span>
											<span style="font-size:0.14rem;">{{row.unit}}</span>
										</span>
									</td>
									<td>
										<span v-show="row.unitPrice===0||(row.unitPrice)">￥{{row.unitPrice}}</span>
									</td>
									<td>
										<span v-show="row.totalMoney===0||(row.totalMoney)">￥{{row.totalMoney}}</span>
									</td>
									<td>
										<span v-show="row.discountMoney===0||(row.discountMoney)">￥{{row.discountMoney}}</span>
									</td>
									<td>
										<span v-show="row.realMoney===0||(row.realMoney)">￥{{row.realMoney}}</span>
									</td>
									<td>{{row.createTime}}</td>
									<td>{{row.payModeName}}</td>
									<td>{{row.orderState}}</td>
									<td>
										<el-button v-if="row.opratetype!=1" style="font-size:0.16rem;" @click="moneyTableRowClick(row)"
										type="text" size="medium">详情</el-button>
										<el-button v-if="row.opratetype==1 && hasApi('orderManage_payOrder')" style="font-size:0.16rem;" @click="reselectPayMode(row)"
										type="text" size="medium">支付</el-button>
									</td>
								</template>
								
							</tr>
						</tbody>
						<tbody v-else>
							<tr>
								<td colspan="13" align="center">暂无数据</td>
							</tr>
						</tbody>
					</table>
					<!-- 退费订单 -->
					<table v-show="ordertype==3" class="table coverTable"
					 cellspacing="0" style="width: 100%;">
						<thead class="thead">
							<tr>
								<td>退费单号</td>
								<td>退费学员</td>
								<td></td>
								<td>课程/商品/订金</td>
								<td>退费数量/单位</td>
								<td>退费金额</td>
								<td>退费申请时间</td>
								<td>退费审核时间</td>
								<td>退费审核</td>
								<td>状态</td>
								<td>操作</td>
							</tr>
						</thead>
						<tbody class="tbody"  v-if="moneyTableData&&moneyTableData.length>0">
							<tr v-for="(row,index) in moneyTableData" :key="index"
							 :rowIndex="row.primaryIndex%2===0?'even':'odd'"
							 @mouseenter="tableRowHoverIndex=row.primaryIndex"
							 @mousemove="tableRowHoverIndex=row.primaryIndex"
							 @mouseleave="tableRowHoverIndex=-1"
							 :rowhover="row.primaryIndex==tableRowHoverIndex?'1':'0'"
							 >
								<template v-if="row.isCombine">
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.orderNo}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.studentName}}</td>
									<td >
										<div class="orderTypeSymbol" :type="row.ordertype" v-if="row.ordertype==1">课</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==2">商</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==3">订</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==4">餐</div>
									</td>
									<td>{{row.orderName}}</td>
									<td>
										<span v-show="row.refundNumber===0||(row.refundNumber)">
											<!-- {{row.refundNumber+'/'+row.unit}} -->
											<span>{{row.refundNumber+' /'}}</span>
											<span style="font-size:0.14rem;">{{row.unit}}</span>
										</span>
									</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">
										<span v-show="row.refundMoney===0||(row.refundMoney)">￥{{row.refundMoney}}</span>
									</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.createTime}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.auditorTime}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.auditorUserName}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.orderState}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">
										<el-button style="font-size:0.16rem;" @click="moneyTableRowClick(row)"
										type="text" size="medium">详情</el-button>
									</td>
								</template>
								<template v-else>
									<td>{{row.orderNo}}</td>
									<td>{{row.studentName}}</td>
									<td >
										<div class="orderTypeSymbol" :type="row.ordertype" v-if="row.ordertype==1">课</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==2">商</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==3">订</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==4">餐</div>
									</td>
									<td>{{row.orderName}}</td>
									<td>
										<span v-show="row.refundNumber===0||(row.refundNumber)">
											<!-- {{row.refundNumber+'/'+row.unit}} -->
											<span>{{row.refundNumber+' /'}}</span>
											<span style="font-size:0.14rem;">{{row.unit}}</span>
										</span>
									</td>
									<td>
										<span v-show="row.refundMoney===0||(row.refundMoney)">￥{{row.refundMoney}}</span>
									</td>
									<td>{{row.createTime}}</td>
									<td>{{row.auditorTime}}</td>
									<td>{{row.auditorUserName}}</td>
									<td>{{row.orderState}}</td>
									<td>
										<el-button style="font-size:0.16rem;" @click="moneyTableRowClick(row)"
										type="text" size="medium">详情</el-button>
									</td>
								</template>
							</tr>
						</tbody>
						<tbody v-else>
							<tr>
								<td colspan="11" align="center">暂无数据</td>
							</tr>
						</tbody>
					</table>
					<!-- 已取消订单 -->
					<table v-show="ordertype==4" class="table coverTable"
					 cellspacing="0" style="width: 100%;">
						<thead class="thead">
							<tr>
								<td>订单号</td>
								<td></td>
								<td>课程/商品/订金</td>
								<td>购买学员</td>
								<td>购买数量/单位</td>
								<!-- <td>单价</td> -->
								<!-- <td>总计</td> -->
								<!-- <td>优惠金额</td> -->
								<td>实际支付</td>
								<td>取消时间</td>
								<!-- <td>支付方式</td> -->
								<td>状态</td>
								<td>操作</td>
							</tr>
						</thead>
						<tbody class="tbody" v-if="moneyTableData&&moneyTableData.length>0">
							<tr v-for="(row,index) in moneyTableData" :key="index"
							 :rowIndex="row.primaryIndex%2===0?'even':'odd'"
							 @mouseenter="tableRowHoverIndex=row.primaryIndex"
							 @mousemove="tableRowHoverIndex=row.primaryIndex"
							 @mouseleave="tableRowHoverIndex=-1"
							 :rowhover="row.primaryIndex==tableRowHoverIndex?'1':'0'">
								<template v-if="row.isCombine">
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.orderNo}}</td>
									<td>
										<div class="orderTypeSymbol" :type="row.ordertype" v-if="row.ordertype==1">课</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==2">商</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==3">订</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==4">餐</div>
									</td>
									<td>{{row.orderName}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.studentName}}</td>
									<td>
										<span v-show="row.buyNumber===0||(row.buyNumber)">
											<!-- {{row.buyNumber+'/'+row.unit}} -->
											<span>{{row.buyNumber+' /'}}</span>
											<span style="font-size:0.14rem;">{{row.unit}}</span>
										</span>
									</td>
									<!-- <td >
										<span v-show="row.unitPrice===0||(row.unitPrice)">￥{{row.unitPrice}}</span>
									</td>
									<td >
										<span v-show="row.totalMoney===0||(row.totalMoney)">￥{{row.totalMoney}}</span>
									</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">
										<span v-show="row.discountMoney===0||(row.discountMoney)">￥{{row.discountMoney}}</span>
									</td> -->
									<td v-if="row.combineType==1" :rowspan="row.combineRows">
										<span v-show="row.realMoney===0||(row.realMoney)">￥{{row.realMoney}}</span>
									</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.createTime}}</td>
									<!-- <td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.payModeName}}</td> -->
									<td v-if="row.combineType==1" :rowspan="row.combineRows">{{row.orderState}}</td>
									<td v-if="row.combineType==1" :rowspan="row.combineRows">
										<el-button v-if="row.opratetype!=1" style="font-size:0.16rem;" @click="moneyTableRowClick(row)"
										type="text" size="medium">详情</el-button>
										<el-button v-if="row.opratetype==1 && hasApi('orderManage_payOrder')" style="font-size:0.16rem;" @click="reselectPayMode(row)"
										type="text" size="medium">支付</el-button>
									</td>
								</template>
								<template v-else>
									<td>{{row.orderNo}}</td>
									<td >
										<div class="orderTypeSymbol" :type="row.ordertype" v-if="row.ordertype==1">课</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==2">商</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==3">订</div>
										<div class="orderTypeSymbol" :type="row.ordertype" v-else-if="row.ordertype==4">餐</div>
									</td>
									<td>{{row.orderName}}</td>
									<td>{{row.studentName}}</td>
									<td>
										<span v-show="row.buyNumber===0||(row.buyNumber)">
											<!-- {{row.buyNumber+'/'+row.unit}} -->
											<span>{{row.buyNumber+' /'}}</span>
											<span style="font-size:0.14rem;">{{row.unit}}</span>
										</span>
									</td>
									<!-- <td>
										<span v-show="row.unitPrice===0||(row.unitPrice)">￥{{row.unitPrice}}</span>
									</td>
									<td>
										<span v-show="row.totalMoney===0||(row.totalMoney)">￥{{row.totalMoney}}</span>
									</td>
									<td>
										<span v-show="row.discountMoney===0||(row.discountMoney)">￥{{row.discountMoney}}</span>
									</td> -->
									<td>
										<span v-show="row.realMoney===0||(row.realMoney)">￥{{row.realMoney}}</span>
									</td>
									<td>{{row.createTime}}</td>
									<!-- <td>{{row.payModeName}}</td> -->
									<td>{{row.orderState}}</td>
									<td>
										<el-button style="font-size:0.16rem;" @click="moneyTableRowClick(row)"
										type="text" size="medium">详情</el-button>
									</td>
								</template>
								
							</tr>
						</tbody>
						<tbody v-else>
							<tr>
								<td colspan="9" align="center">暂无数据</td>
							</tr>
						</tbody>
					</table>
				</template>

				<div class="bottomControlsBox">
					<div class="totalBox">
						
					</div>
					<el-pagination
						:page-sizes="[10, 20, 30, 40,50,100]"
						:page-size="searchListParam.pageSize"
						layout="total, sizes, prev, pager, next, jumper"
						:total="pagination.total"
						:current-page="searchListParam.currPage"
						@current-change="handleCurrentChange"
						@size-change="handleSizeChange">
					</el-pagination>
				</div>
				
			</div>
			
			<!-- 收费订单详情 -->
			<el-dialog class="chargespopup" :title="chargeDetailsPopup.title"
			 :visible.sync="chargeDetailsPopup.visible"
			 :close-on-click-modal="false">
				<allordersChargeDetails ref="allordersChargeDetails"
				 @hideMe="hideChargesPopup" @success="updateMoneyList"
				 @gotoPay="payTableRow"></allordersChargeDetails>
			</el-dialog>
			<!-- 退费订单详情 -->
			<el-dialog class="chargespopup" :title="refundDetailsPopup.title" :visible.sync="refundDetailsPopup.visible">
				<allordersRefundDetails ref="allordersRefundDetails"
				 @hideMe="hideChargesPopup" @success="updateMoneyList"></allordersRefundDetails>
			</el-dialog>
			<!-- 支付 -->
			<!-- <enrollPay v-show="enrollPayPopup.visible" ref="enrollPay" @ok="enrollPaypayOk"
			 @back="enrollPaybackConfirm"></enrollPay> -->
			 <payQRCode ref="payQRCode" @callback="suceessPay" @cancel="cancelPay"></payQRCode>
			<!-- 支付成功反馈弹窗 -->
			<!-- <el-dialog class="paySuccess"
			:modal="false"
			style="background: rgba(0,0,0,0.5);"
			:visible.sync="paySuccess.paySuccessVisible"
			>
				<enrollsuccess ref="enrollsuccess"></enrollsuccess>
			</el-dialog> -->

		</div>
		
		
	</div>
</template>

<script>
	import allordersChargeDetails from './common/allorders_charge_details'
	import allordersRefundDetails from './common/allorders_refund_details'
	// import enrollPay from "@/components/clue_manage/subpage/clue_enroll_pay";
	import payQRCode from "@/components/common/payQRCode";
	// import enrollsuccess from "./common/pay_success";
	import fNumber from "@/js/utils/floatnumber.js"
	let vm;
	export default{
		components:{allordersChargeDetails,allordersRefundDetails,payQRCode},
		data(){
			return {
				ordertype:1,
				/**订单搜索 */
				searchListParam:{
					campusId:this.$store.state.campusId,
					pageSize:10,
					// queryType:2,//1-全部订单，2-待支付订单，3-已退费订单
					// billMode:'',
					// accountUserId:'',
					currPage:1,
					// payMode:'',
					keyName:'',
					startTime:'',
					endTime:'',
					orderState:0,//0-全部，1-待支付，2-交易成功，3-交易关闭
					auditState:2,//0-全部，1-待审核，2-已审核
					auditType:1,//1-收费，2-退费
				},
				headControls:{
					datePickerValue:null,
					selectObj:{
						data:[
							{
								label:'待支付',
								value:'1'
							},
							{
								label:'交易成功',
								value:'2'
							},
							{
								label:'交易关闭',
								value:'3'
							},
						],
						select:''
					},
					param:'',
				},
				moneyTableData: [],
				tableRowHoverIndex:-1,
				/**分页 */
				pagination:{
					total:0
				},
				//订单详情弹窗
				chargeDetailsPopup:{
					visible:false,
					title:'详情'
				},
				//退费订单详情弹窗
				refundDetailsPopup:{
					visible:false,
					title:'退款详情'
				},
				enrollPayPopup:{
					visible:false,

				},
				paySuccess:{
					paySuccessVisible:false,

				},
				exportstate: false, //导出excel按钮状态 true为正在下载
				exportNotification: null, //导出excel状态通知
				//日期有效性计算
				picker_mintime:(new Date()).setMonth((new Date()).getMonth()-3),
				picker_maxtime:(new Date()).setHours(23,59,59,0),
				// pickerOptions : {
				// 	disabledDate : function(date) {
				// 		if(date.getTime()>=vm.picker_mintime&&date.getTime()<=vm.picker_maxtime)
				// 			return false;
				// 		else
				// 			return true;
				// 	}
				// },
			};
		},
		methods:{
			init(){
				// this._billmode=this._dictData.bill_mode;
				vm._combineIndex=[];
				this.resetSearchParam();//重置搜索条件
				this.updateMoneyList();//收费列表
			},
			campusChange : function(campusId) { //校区改变
				this.campusChangeHandle(campusId);
			},
			campusChangeHandle(campusId) { //校区改变
				this.searchListParam.campusId = campusId;
				this.init();
			},
			/**切换类型：1-全部订单；2-待支付订单；3-退费订单；4-已取消订单 */
			changeOrderType(type){
				this.ordertype=type;
				this.searchListParam.auditState=2;
				if(type==1){
					this.searchListParam.orderState=0;
					this.searchListParam.auditType=1;
				}
				else if(type==2){
					this.searchListParam.orderState=1;
					this.searchListParam.auditType=1;
					this.searchListParam.auditState=1;
				}
				else if(type==3){
					this.searchListParam.orderState=3;
					this.searchListParam.auditType=2;
				}
				else if(type==4){
					this.searchListParam.auditType=1;
					this.searchListParam.auditState=3;
					this.searchListParam.orderState='0';
				}
				
				this.resetSearchParam();
				this.moneyTableData=[];
				this.$nextTick(()=>{
					this.updateMoneyList();//收费列表
				});
				
			},
			/**重置搜索条件（包括输入框的文本） */
			resetSearchParam(){
				//重置翻页
				this.searchListParam.pageSize=10;
				this.searchListParam.currPage=1;
				//重置时间
				this.searchListParam.startTime=tool.DateToString(new Date(this.picker_mintime),'yyyy-MM-dd HH:mm:ss');
				this.searchListParam.endTime=tool.DateToString(new Date(this.picker_maxtime),'yyyy-MM-dd HH:mm:ss');
				this.headControls.datePickerValue=null;
				//重置输入框
				this.searchListParam.keyName='';
				this.headControls.param='';
				//重置下拉框
				this.headControls.selectObj.select='';
				// this.searchListParam.orderState=0;
			},
			/**更新收费列表数据*/
			updateMoneyList(currPage){
				this.searchListParam.currPage=1;
				if(currPage){
					this.searchListParam.currPage=currPage;
				}
				api.orderManage_queryInList(this.searchListParam)
				.then(function(d){
					// console.log(d)
					if(d.result=='操作成功'){
						vm.formateTableData(d);
					}
				});
			},
			/**格式化数据 */
			formateTableData(data){
				let result=[],combineIndex=[];
				this.pagination.total=data.totalCount;
				if(this.ordertype==1||this.ordertype==2){
					for(let i=0;i<data.list.length;i++){
						let row=data.list[i];
						let orderSignupEntity=row.orderSignupEntity,//报名订单数据
						orderRefundEntity=row.orderRefundEntity,//退费订单数据
						signupCourseData=row.signupCourseData,//报名课程数据
						refundCourseData=row.refundCourseData,//退费课程数据
						refundGoodsData=row.refundGoodsData,//退费商品数据
						signupGoodsData=row.signupGoodsData,//报名商品数据
						signupMealsData=row.signupMealsData,//收餐费
						refundMealsData=row.refundMealsData;//退餐费

						let entityObj=orderSignupEntity||orderRefundEntity;
						let combineRow=[];
						let daizhifu=false;
						if(entityObj.orderPayState==1)daizhifu='待支付';
						if(signupCourseData&&signupCourseData.length>0){
							let newdata=[];
							signupCourseData.forEach(ele=>{
								let ordername='';
								if(ele.className&&ele.courseName){
									// ordername=ele.className+'/'+ele.courseName;
									ordername=ele.className+'\n'+ele.courseName;
								}
								else{
									ordername=ele.className||ele.courseName;
									ordername=ordername||'';
								}
								let unitObj=vm.getCourseUnitPrice(1,ele);//获取课程单价和单位
								let p_shouldPayMoney=fNumber.subtract(ele.courseMoney,ele.discountMoney);
								if(p_shouldPayMoney<0)p_shouldPayMoney=0;
								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									orderNo:entityObj.orderSigupId,//订单号
									ordertype:1,//类型 1~4：课 商 订 餐
									orderName:ordername,//订单名称
									studentName:row.studentName,//
									buyNumber:ele.courseBuyNum,//购买数量
									unit:unitObj.unit,//单位
									unitPrice:unitObj.unitPrice,//单价
									totalMoney:ele.courseMoney,//总计
									discountMoney:entityObj.discount,//优惠金额
									realMoney:entityObj.realMoney,//实际支付
									createTime:(entityObj.orderTime||"").substr(0,10),//下单时间
									payModeName:tool.getDictNameByValue(entityObj.payMode,'pay_mode'),//支付方式
									orderState:tool.getDictNameByValue(entityObj.orderPayState,'order_pay_state'),//状态
									opratetype:entityObj.orderPayState,//判断操作

									//弹窗字段
									p_ordertype:1,//类型 1~4：课 商 订 餐
									p_orderName:ordername,//订单名称
									p_unitPrice:unitObj.unitPrice,//单价
									p_unit:unitObj.unit,//单位
									p_buyNumber:ele.courseBuyNum,//购买数量
									p_totalMoney:ele.courseMoney,//总计、合计
									p_discountMoney:ele.discountMoney,//优惠金额
									p_discountName:ele.couponEntity?ele.couponEntity.couponName:'--',//优惠名称
									p_depositDiscountMoney:'',//订金减扣
									p_shouldPayMoney:p_shouldPayMoney,//应支付
									p_orderState:daizhifu||tool.getDictNameByValue(ele.courseState,'course_status'),//状态
									p_allowRefundDays:'',//符合退费天数
									p_shouldRefundMoney:'',//应退费金额
									p_preClassMoney:'',//原班剩余费用
									p_changeClassMoney:ele.realMoney,//转班支付
									p_orderSignupCourseId:ele.orderSignupCourseId,//查询转班详情id
									p_classId:ele.classId,//班级id
								}
								//转班
								if(entityObj.orderMode===3||entityObj.refundMode===5){
									let unitPrice2=fNumber.divide(ele.coursePackage.totalMoney,ele.coursePackage.courseHour);
									if(ele.coursePackage.chargeMode == 3){
										unitPrice2=fNumber.divide(ele.coursePackage.totalMoney,ele.totalCourseHour);
									}
									newrow.p_shouldPayMoney=entityObj.receivableMoney;//应支付
									newrow.p_changeClassMoney=entityObj.receivableMoney;//转班支付
									newrow.p_totalMoney=fNumber.multiply(unitPrice2,ele.courseBuyNum);
									// newrow.p_totalMoney=newrow.p_totalMoney>ele.coursePackage.totalMoney?
									// ele.coursePackage.totalMoney:newrow.p_totalMoney;
									newrow.p_preClassMoney=fNumber.subtract(newrow.p_totalMoney,ele.realMoney);
								}
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						if(signupGoodsData&&signupGoodsData.length>0){
							let newdata=[];
							signupGoodsData.forEach(ele=>{
								let p_orderState=daizhifu||(ele.courseState==3?'已退费':'正常');
								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									orderNo:entityObj.orderSigupId,//订单号
									ordertype:2,//类型 1~4：课 商 订 餐
									orderName:ele.goodsName,//订单名称
									studentName:row.studentName,//
									buyNumber:ele.goodsNum,//购买数量
									unit:'个',//单位
									unitPrice:ele.goodsOneMoney,//单价
									totalMoney:ele.totalMoney,//总计
									discountMoney:entityObj.discount,//优惠金额
									realMoney:entityObj.realMoney,//实际支付
									createTime:(entityObj.orderTime||"").substr(0,10),//下单时间
									payModeName:tool.getDictNameByValue(entityObj.payMode,'pay_mode'),//支付方式
									orderState:tool.getDictNameByValue(entityObj.orderPayState,'order_pay_state'),//状态
									opratetype:entityObj.orderPayState,//判断操作

									//弹窗字段
									p_ordertype:2,//类型 1~4：课 商 订 餐
									p_orderName:ele.goodsName,//订单名称
									p_unitPrice:ele.goodsOneMoney,//单价
									p_unit:'个',//单位
									p_buyNumber:ele.goodsNum,//购买数量
									p_totalMoney:ele.totalMoney,//总计、合计
									p_discountMoney:'',//优惠金额
									p_discountName:'',//优惠名称
									p_depositDiscountMoney:'',//订金减扣
									p_shouldPayMoney:ele.realMoney,//应支付
									p_orderState:p_orderState,//状态
									p_allowRefundDays:'',//符合退费天数
									p_shouldRefundMoney:'',//应退费金额
									p_preClassMoney:'',//原班剩余费用
    								p_changeClassMoney:'',//转班支付

								}
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						if(signupMealsData&&signupMealsData.length>0){
							let newdata=[];
							signupMealsData.forEach(ele=>{
								let combinename=ele.mealsName;
								if(ele.useTime){
									let timearr=ele.useTime.split('-');
									combinename=ele.mealsName+'('+timearr[1]+'月)';
								}
								let p_orderState=daizhifu||(ele.courseState==3?'已退费':'正常');
								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									mealsId:ele.mealsId,
									mealsType:ele.type,
									startTimeSettlement:ele.startTimeSettlement,
									endTimeSettlement:ele.endTimeSettlement,
									orderNo:entityObj.orderSigupId,//订单号
									ordertype:4,//类型 1~4：课 商 订 餐
									orderName:combinename,//订单名称
									studentName:row.studentName,//
									buyNumber:ele.mealsNum,//购买数量
									unit:'元/天',//单位
									unitPrice:ele.price,//单价
									totalMoney:ele.totalMoney,//总计
									discountMoney:entityObj.discount,//优惠金额
									realMoney:entityObj.realMoney,//实际支付
									createTime:(entityObj.orderTime||"").substr(0,10),//下单时间
									payModeName:tool.getDictNameByValue(entityObj.payMode,'pay_mode'),//支付方式
									orderState:tool.getDictNameByValue(entityObj.orderPayState,'order_pay_state'),//状态
									opratetype:entityObj.orderPayState,//判断操作

									//弹窗字段
									p_ordertype:4,//类型 1~4：课 商 订 餐
									p_orderName:combinename,//订单名称
									p_unitPrice:ele.price,//单价
									p_unit:'元/天',//单位
									p_buyNumber:ele.mealsNum,//购买数量
									p_totalMoney:ele.totalMoney,//总计、合计
									p_discountMoney:'',//优惠金额
									p_discountName:'',//优惠名称
									p_depositDiscountMoney:'',//订金减扣
									p_shouldPayMoney:ele.receivableMoney,//应支付
									p_orderState:p_orderState,//状态
									p_allowRefundDays:ele.leaveDays,//符合退费天数
									p_shouldRefundMoney:ele.balanceMoney,//应退费金额
									p_preClassMoney:'',//原班剩余费用
    								p_changeClassMoney:'',//转班支付
								}
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						
						let start=result.length;
						let count=combineRow.length;
						if(count>1){
							combineRow[0].isCombine=true;
							combineRow[0].combineType=1;
							combineRow[0].combineRows=count;
							for(let k=1;k<combineRow.length;k++){
								combineRow[k].isCombine=true;
								combineRow[k].combineType=2;
							}

							combineIndex.push({index:start,count:count});
						}
						result=result.concat(combineRow);
					}
				}
				else if(this.ordertype==3){
					for(let i=0;i<data.list.length;i++){
						let row=data.list[i];
						let orderSignupEntity=row.orderSignupEntity,//报名订单数据
						orderRefundEntity=row.orderRefundEntity,//退费订单数据
						signupCourseData=row.signupCourseData,//报名课程数据
						refundCourseData=row.refundCourseData,//退费课程数据
						refundGoodsData=row.refundGoodsData,//退费商品数据
						signupGoodsData=row.signupGoodsData,//报名商品数据
						signupMealsData=row.signupMealsData,//收餐费
						refundMealsData=row.refundMealsData;//退餐费

						let entityObj=orderSignupEntity||orderRefundEntity;
						let combineRow=[];
						
						if(refundCourseData&&refundCourseData.length>0){
							let newdata=[];
							refundCourseData.forEach(ele=>{
								let ordername='';
								if(ele.className&&ele.courseName){
									// ordername=ele.className+'/'+ele.courseName;
									ordername=ele.className+'\n'+ele.courseName;
								}
								else{
									ordername=ele.className||ele.courseName;
									ordername=ordername||'';
								}
								let unitObj=vm.getCourseUnitPrice(2,ele);//获取课程单价和单位

								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									orderNo:entityObj.orderRefundId,//订单号
									studentName:row.studentName,//
									ordertype:1,//类型 1~4：课 商 订 餐
									orderName:ordername,//订单名称
									refundNumber:ele.surplusClassHour,//退费数量
									unit:unitObj.unit,//单位
									refundMoney:entityObj.relMoney,//退费金额
									createTime:entityObj.createTime,//退费申请时间
									auditorTime:entityObj.auditorTime,//退费审核时间
									auditorUserName:entityObj.auditorUserName,//退费审核人
									orderState:tool.getDictNameByValue(entityObj.orderRefundState,'order_refund_state'),//状态
									opratetype:3,//判断操作

									//弹窗字段
									p_orderNo:entityObj.orderRefundId,//订单号
									p_ordertype:1,//类型 1~4：课 商 订 餐
									p_orderName:ordername,//订单名称
									p_unitPrice:unitObj.unitPrice,//单价
									p_unit:unitObj.unit,//单位
									p_buyNumber:ele.buyHour,//购买数量
									p_payModeName:tool.getDictNameByValue(ele.payMode,'pay_mode'),//支付方式
									p_totalMoney:ele.courseTotalPrice,//总计、合计
									p_discountMoney:ele.discountMoney,//优惠金额
									p_discountName:ele.couponEntity?ele.couponEntity.couponName:'--',//优惠名称
									p_realPayMoney:ele.realMoney,//实际支付
									p_refundNumber:ele.surplusClassHour,//退费数量
									p_shouldRefundMoney:ele.refundMeoey,//应退费
									p_realRefundMoney:ele.realPayMoney,//实际退费
									p_orderRefundCourseId:ele.studentCourseId,//查询转班详情id
									p_classId:ele.classId,//班级id
								};
								//转班
								if(entityObj.orderMode===3||entityObj.refundMode===5){
									newrow.p_totalMoney=fNumber.multiply(unitObj.unitPrice,ele.buyHour);
								}
								//全日制课程退费
								if(ele.courseType==2){
									newrow.refundNumber='-';
									newrow.p_refundNumber='-';
								}
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						if(refundGoodsData&&refundGoodsData.length>0){
							let newdata=[];
							refundGoodsData.forEach(ele=>{
								
								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									orderNo:entityObj.orderRefundId,//订单号
									studentName:row.studentName,//
									ordertype:2,//类型 1~4：课 商 订 餐
									orderName:ele.goodsName,//订单名称
									refundNumber:ele.goodsNum,//退费数量
									unit:'个',//单位
									refundMoney:entityObj.relMoney,//退费金额
									createTime:entityObj.createTime,//退费申请时间
									auditorTime:entityObj.auditorTime,//退费审核时间
									auditorUserName:entityObj.auditorUserName,//退费审核人
									orderState:tool.getDictNameByValue(entityObj.orderRefundState,'order_refund_state'),//状态
									opratetype:3,//判断操作

									//弹窗字段
									p_orderNo:entityObj.orderRefundId,//订单号
									p_ordertype:2,//类型 1~4：课 商 订 餐
									p_orderName:ele.goodsName,//订单名称
									p_unitPrice:ele.goodsOneMoney,//单价
									p_unit:'个',//单位
									p_buyNumber:ele.goodsNum,//购买数量
									p_payModeName:tool.getDictNameByValue(ele.payMode,'pay_mode'),//支付方式
									p_totalMoney:ele.totalMoney,//总计、合计
									p_discountMoney:'',//优惠金额
									p_discountName:'',//优惠名称
									p_realPayMoney:ele.realMoney,//实际支付
									p_refundNumber:ele.goodsNum,//退费数量
									p_shouldRefundMoney:ele.realMoney,//应退费
									p_realRefundMoney:'',//实际退费
								};
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						if(refundMealsData&&refundMealsData.length>0){
							let newdata=[];
							refundMealsData.forEach(ele=>{
								let combinename=ele.mealsName;
								if(ele.useTime){
									let timearr=ele.useTime.split('-');
									combinename=ele.mealsName+'('+timearr[1]+'月)';
								}
								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									orderNo:entityObj.orderRefundId,//订单号
									studentName:row.studentName,//
									ordertype:4,//类型 1~4：课 商 订 餐
									orderName:combinename,//订单名称
									refundNumber:ele.mealsNum,//退费数量
									unit:'元/天',//单位
									refundMoney:entityObj.relMoney,//退费金额
									createTime:entityObj.createTime,//退费申请时间
									auditorTime:entityObj.auditorTime,//退费审核时间
									auditorUserName:entityObj.auditorUserName,//退费审核人
									orderState:tool.getDictNameByValue(entityObj.orderRefundState,'order_refund_state'),//状态
									opratetype:3,//判断操作

									//弹窗字段
									p_orderNo:entityObj.orderRefundId,//订单号
									p_ordertype:4,//类型 1~4：课 商 订 餐
									p_orderName:combinename,//订单名称
									p_unitPrice:ele.price,//单价
									p_unit:'元/天',//单位
									p_buyNumber:ele.mealsNum,//购买数量
									p_payModeName:tool.getDictNameByValue(ele.payMode,'pay_mode'),//支付方式
									p_totalMoney:ele.totalMoney,//总计、合计
									p_discountMoney:'',//优惠金额
									p_discountName:'',//优惠名称
									p_realPayMoney:ele.totalMoney,//实际支付
									p_refundNumber:ele.mealsNum,//退费数量
									p_shouldRefundMoney:ele.payableMoney,//应退费
									p_realRefundMoney:'',//实际退费
								};
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						
						let start=result.length;
						let count=combineRow.length;
						if(count>1){
							combineRow[0].isCombine=true;
							combineRow[0].combineType=1;
							combineRow[0].combineRows=count;
							for(let k=1;k<combineRow.length;k++){
								combineRow[k].isCombine=true;
								combineRow[k].combineType=2;
							}

							combineIndex.push({index:start,count:count});
						}
						result=result.concat(combineRow);
					}
				}
				else if(this.ordertype==4){
					for(let i=0;i<data.list.length;i++){
						let row=data.list[i];
						let orderSignupEntity=row.orderSignupEntity,//报名订单数据
						orderRefundEntity=row.orderRefundEntity,//退费订单数据
						signupCourseData=row.signupCourseData,//报名课程数据
						refundCourseData=row.refundCourseData,//退费课程数据
						refundGoodsData=row.refundGoodsData,//退费商品数据
						signupGoodsData=row.signupGoodsData,//报名商品数据
						signupMealsData=row.signupMealsData,//收餐费
						refundMealsData=row.refundMealsData;//退餐费

						let entityObj=orderSignupEntity||orderRefundEntity;
						let combineRow=[];
						let daizhifu=false;
						if(entityObj.orderPayState==1)daizhifu='待支付';
						if(signupCourseData&&signupCourseData.length>0){
							let newdata=[];
							signupCourseData.forEach(ele=>{
								let ordername='';
								if(ele.className&&ele.courseName){
									// ordername=ele.className+'/'+ele.courseName;
									ordername=ele.className+'\n'+ele.courseName;
								}
								else{
									ordername=ele.className||ele.courseName;
									ordername=ordername||'';
								}
								let unitObj=vm.getCourseUnitPrice(1,ele);//获取课程单价和单位
								let p_shouldPayMoney=fNumber.subtract(ele.courseMoney,ele.discountMoney);
								if(p_shouldPayMoney<0)p_shouldPayMoney=0;
								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									orderNo:entityObj.orderSigupId,//订单号
									ordertype:1,//类型 1~4：课 商 订 餐
									orderName:ordername,//订单名称
									studentName:row.studentName,//
									buyNumber:ele.courseBuyNum,//购买数量
									unit:unitObj.unit,//单位
									unitPrice:unitObj.unitPrice,//单价
									totalMoney:ele.courseMoney,//总计
									discountMoney:entityObj.discount,//优惠金额
									realMoney:entityObj.realMoney,//实际支付
									createTime:(entityObj.orderTime||"").substr(0,10),//下单时间
									payModeName:tool.getDictNameByValue(entityObj.payMode,'pay_mode'),//支付方式
									orderState:tool.getDictNameByValue(entityObj.orderPayState,'order_pay_state'),//状态
									opratetype:entityObj.orderPayState,//判断操作

									//弹窗字段
									p_ordertype:1,//类型 1~4：课 商 订 餐
									p_orderName:ordername,//订单名称
									p_unitPrice:unitObj.unitPrice,//单价
									p_unit:unitObj.unit,//单位
									p_buyNumber:ele.courseBuyNum,//购买数量
									p_totalMoney:ele.courseMoney,//总计、合计
									p_discountMoney:ele.discountMoney,//优惠金额
									p_discountName:ele.couponEntity?ele.couponEntity.couponName:'--',//优惠名称
									p_depositDiscountMoney:'',//订金减扣
									p_shouldPayMoney:p_shouldPayMoney,//应支付
									p_orderState:'交易关闭',//状态
									p_allowRefundDays:'',//符合退费天数
									p_shouldRefundMoney:'',//应退费金额
									p_preClassMoney:'',//原班剩余费用
									p_changeClassMoney:ele.realMoney,//转班支付
									p_orderSignupCourseId:ele.orderSignupCourseId,//查询转班详情id
									p_classId:ele.classId,//班级id
								}
								//转班
								if(entityObj.orderMode===3||entityObj.refundMode===5){
									let unitPrice2=fNumber.divide(ele.coursePackage.totalMoney,ele.coursePackage.courseHour);
									if(ele.coursePackage.chargeMode == 3){
										unitPrice2=fNumber.divide(ele.coursePackage.totalMoney,ele.totalCourseHour);
									}
									newrow.p_shouldPayMoney=entityObj.receivableMoney;//应支付
									newrow.p_changeClassMoney=entityObj.receivableMoney;//转班支付
									newrow.p_totalMoney=fNumber.multiply(unitPrice2,ele.courseBuyNum);
									// newrow.p_totalMoney=newrow.p_totalMoney>ele.coursePackage.totalMoney?
									// ele.coursePackage.totalMoney:newrow.p_totalMoney;
									newrow.p_preClassMoney=fNumber.subtract(newrow.p_totalMoney,ele.realMoney);
								}
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						if(signupGoodsData&&signupGoodsData.length>0){
							let newdata=[];
							signupGoodsData.forEach(ele=>{
								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									orderNo:entityObj.orderSigupId,//订单号
									ordertype:2,//类型 1~4：课 商 订 餐
									orderName:ele.goodsName,//订单名称
									studentName:row.studentName,//
									buyNumber:ele.goodsNum,//购买数量
									unit:'个',//单位
									unitPrice:ele.goodsOneMoney,//单价
									totalMoney:ele.totalMoney,//总计
									discountMoney:entityObj.discount,//优惠金额
									realMoney:entityObj.realMoney,//实际支付
									createTime:(entityObj.orderTime||"").substr(0,10),//下单时间
									payModeName:tool.getDictNameByValue(entityObj.payMode,'pay_mode'),//支付方式
									orderState:tool.getDictNameByValue(entityObj.orderPayState,'order_pay_state'),//状态
									opratetype:entityObj.orderPayState,//判断操作

									//弹窗字段
									p_ordertype:2,//类型 1~4：课 商 订 餐
									p_orderName:ele.goodsName,//订单名称
									p_unitPrice:ele.goodsOneMoney,//单价
									p_unit:'个',//单位
									p_buyNumber:ele.goodsNum,//购买数量
									p_totalMoney:ele.totalMoney,//总计、合计
									p_discountMoney:'',//优惠金额
									p_discountName:'',//优惠名称
									p_depositDiscountMoney:'',//订金减扣
									p_shouldPayMoney:ele.realMoney,//应支付
									p_orderState:'交易关闭',//状态
									p_allowRefundDays:'',//符合退费天数
									p_shouldRefundMoney:'',//应退费金额
									p_preClassMoney:'',//原班剩余费用
    								p_changeClassMoney:'',//转班支付

								}
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						if(signupMealsData&&signupMealsData.length>0){
							let newdata=[];
							signupMealsData.forEach(ele=>{
								let combinename=ele.mealsName;
								if(ele.useTime){
									let timearr=ele.useTime.split('-');
									combinename=ele.mealsName+'('+timearr[1]+'月)';
								}
								let newrow={
									//公共属性
									primaryIndex:i,//原数据索引

									//一级字段
									mealsId:ele.mealsId,
									mealsType:ele.type,
									startTimeSettlement:ele.startTimeSettlement,
									endTimeSettlement:ele.endTimeSettlement,
									orderNo:entityObj.orderSigupId,//订单号
									ordertype:4,//类型 1~4：课 商 订 餐
									orderName:combinename,//订单名称
									studentName:row.studentName,//
									buyNumber:ele.mealsNum,//购买数量
									unit:'元/天',//单位
									unitPrice:ele.price,//单价
									totalMoney:ele.totalMoney,//总计
									discountMoney:entityObj.discount,//优惠金额
									realMoney:entityObj.realMoney,//实际支付
									createTime:(entityObj.orderTime||"").substr(0,10),//下单时间
									payModeName:tool.getDictNameByValue(entityObj.payMode,'pay_mode'),//支付方式
									orderState:tool.getDictNameByValue(entityObj.orderPayState,'order_pay_state'),//状态
									opratetype:entityObj.orderPayState,//判断操作

									//弹窗字段
									p_ordertype:4,//类型 1~4：课 商 订 餐
									p_orderName:combinename,//订单名称
									p_unitPrice:ele.price,//单价
									p_unit:'元/天',//单位
									p_buyNumber:ele.mealsNum,//购买数量
									p_totalMoney:ele.totalMoney,//总计、合计
									p_discountMoney:'',//优惠金额
									p_discountName:'',//优惠名称
									p_depositDiscountMoney:'',//订金减扣
									p_shouldPayMoney:ele.receivableMoney,//应支付
									p_orderState:'交易关闭',//状态
									p_allowRefundDays:ele.leaveDays,//符合退费天数
									p_shouldRefundMoney:ele.balanceMoney,//应退费金额
									p_preClassMoney:'',//原班剩余费用
    								p_changeClassMoney:'',//转班支付
								}
								newdata.push(newrow);
							});
							combineRow=combineRow.concat(newdata);
						}
						
						let start=result.length;
						let count=combineRow.length;
						if(count>1){
							combineRow[0].isCombine=true;
							combineRow[0].combineType=1;
							combineRow[0].combineRows=count;
							for(let k=1;k<combineRow.length;k++){
								combineRow[k].isCombine=true;
								combineRow[k].combineType=2;
							}

							combineIndex.push({index:start,count:count});
						}
						result=result.concat(combineRow);
					}
				}
				// debugger
				this._combineIndex=combineIndex;
				this._primaryTableData=data.list;
				this.moneyTableData=result;
			},
			/**
			 * 获取课程数据单价和单位
			 * @param type 1-收费；2-退费
			 * @param course 课程数据，包含课程包
			 * @returns {unit,unitPrice}
			 */
			getCourseUnitPrice(type,course){
				let unit='课时';
				let unitPrice='';
				if(type==1){
					if(course.coursePackage){
						if(course.coursePackage.chargeMode==3){
							unit=tool.getDictNameByValue(course.coursePackage.courseTimeMode,
							'course_time_mode');
						}
						else{
							// unitPrice = Math.ceil(course.coursePackage.totalMoney * 100 / 
							// (course.coursePackage.courseHour||1)) / 100;
							unitPrice=fNumber.divide(course.coursePackage.totalMoney,course.coursePackage.courseHour);
						}
					}
					else{
						unit="";
					}
				}
				else{
					// unit=course.chargeModeName.replace('按','');
					if(course.coursePackageEntity){
						if(course.coursePackageEntity.chargeMode==3){
							unit=tool.getDictNameByValue(course.coursePackageEntity.courseTimeMode,
							'course_time_mode');
						}
						else{
							// unitPrice = Math.ceil(course.coursePackageEntity.totalMoney * 100 / 
							// (course.coursePackageEntity.courseHour||1)) / 100;
							unitPrice=fNumber.divide(course.coursePackageEntity.totalMoney,
							course.coursePackageEntity.courseHour);
						}
					}
					else{
						unit="";
					}
				}
				//双师课
				if(course.courseType == 4) {
					unit = "节";
				}

				return {unit:unit,unitPrice:unitPrice};
			},
			/**下拉选择 */
			selectObjChange(d){
				this.searchListParam.orderState=d||'0';
			},
			/**搜索条件清空 */
			inputKeyWordsClear(){
				this.searchListParam.keyName='';
			},
			datepickerChange(){
				this.searchListParam.startTime=tool.DateToString(new Date(this.picker_mintime),'yyyy-MM-dd HH:mm:ss');
				this.searchListParam.endTime=tool.DateToString(new Date(this.picker_maxtime),'yyyy-MM-dd HH:mm:ss');
			},
			/**查询按钮点击 */
			queryBtnClick(){
				let time=this.headControls.datePickerValue;
				if(time&&time.length==2){
					this.searchListParam.startTime=time[0];
					this.searchListParam.endTime=time[1];
				}
				else{
					this.searchListParam.startTime=tool.DateToString(new Date(this.picker_mintime),'yyyy-MM-dd HH:mm:ss');
					this.searchListParam.endTime=tool.DateToString(new Date(this.picker_maxtime),'yyyy-MM-dd HH:mm:ss');
				}
				// debugger
				let keywords=this.headControls.param;
				this.searchListParam.keyName=keywords;
				this.updateMoneyList();
			},
			/**表格 行查看点击 */
			moneyTableRowClick(d){
				let primarydata=this._primaryTableData[d.primaryIndex];
				let type=this.ordertype;//1-待支付；2-交易成功；3-交易关闭
				let combineData=[];
				this.moneyTableData.forEach(ele=>{
					if(ele.primaryIndex==d.primaryIndex)
						combineData.push(ele);
				});
				// debugger
				let cloneData=tool.clone(primarydata);
				if(type==1||type==2||type==4){
					cloneData.selectPayMode=d.selectPayMode;
					cloneData.primaryIndex=d.primaryIndex;
					cloneData.isPaysuceess=d.isPaysuceess;
					this.showChargesPopup(cloneData,combineData);
				}
				else if(type==3){
					this.showRefundPopup(cloneData,combineData);
				}
				
			},
			/**表格翻页 */
			handleCurrentChange(val) {
				this.updateMoneyList(val);
			},
			/**切换每页个数 */
			handleSizeChange(val){
				this.searchListParam.pageSize=val;
				this.updateMoneyList();
			},
			/**全部订单-收费订单详情 */
			showChargesPopup(primarydata,combineData){
				if(!primarydata)return;
				// debugger
				this.chargeDetailsPopup.visible=true;
				this.chargeDetailsPopup.title='详情';
				if(primarydata.selectPayMode){
					this.chargeDetailsPopup.title='支付';
				}
				else if(primarydata.isPaysuceess){
					this.chargeDetailsPopup.title='';
				}
				this.$nextTick(()=>{
					let data=vm.formatePopupData(primarydata,combineData,1);
					data.selectPayMode=primarydata.selectPayMode;
					data.primaryIndex=primarydata.primaryIndex;
					data.payMode=primarydata.payMode;
					data.isPaysuceess=primarydata.isPaysuceess;
					data.isCancelOrder=primarydata.orderSignupEntity.orderSignupState==3;
					vm.$refs.allordersChargeDetails.updateByData(data);
				});
				
			},
			/**全部订单-退费订单详情 */
			showRefundPopup(primarydata,combineData){
				if(!primarydata)return;
				
				this.refundDetailsPopup.visible=true;
				this.$nextTick(()=>{
					let data=vm.formatePopupData(primarydata,combineData,2);
					vm.$refs.allordersRefundDetails.updateByData(data);
				});
			},
			/**格式化弹窗详情数据
			 * @param primarydata
			 * @param combineData
			 * @param type 1-收费；2-退费
			 * @returns 格式化后的数据
			 */
			formatePopupData(primarydata,combineData,type){
				let entityObj=primarydata.orderSignupEntity||primarydata.orderRefundEntity;
				//退费方式
				let refundModeName2=tool.getDictNameByValue(entityObj.payMode,'pay_mode');
				if(entityObj.payMode==100){
					refundModeName2='原路返回';
				}
				let result={
					/**收费类型：1-课程、商品订单；2-餐费订单；3-转班订单 */
					// ordertype:1,
					/**学员信息 */
					studentInfo:{
						studentName:primarydata.studentName,
						studentId:entityObj.studentId,
						parentName:primarydata.parentName,
						phoneNumber:primarydata.studentPhone,
						orderTime:(entityObj.orderTime||"").substr(0,10),
						createTime:(entityObj.createTime||""),
						orderNo:entityObj.orderNo,//合同号
					},
					/**表格数据 */
					tableData:combineData,
					tableStatistics:{
						totalMoney:entityObj.totalMoney,
						realMoney:entityObj.realMoney,
						earnestMoney:entityObj.earnestMoney||'0'
					},
					/**其他信息 */
					otherInfo:{
						orderNo:'',//订单号
						otherOrderNo:entityObj.payOrderNo,
						statu:tool.getDictNameByValue(entityObj.orderPayState,'order_pay_state'),
						payMode:refundModeName2,
						executeUserName:primarydata.executeUserName,
						createUserName:primarydata.createUserName,
						mark:''
					},
				};
				if(type===1){
					/**收费类型：1-课程、商品订单；2-餐费订单；3-转班订单 */
					result.ordertype=combineData[0].ordertype;
					//转班
					if(entityObj.orderMode===3||entityObj.refundMode===5){
						result.ordertype=5;
						result.tableStatistics.totalMoney=result.tableData[0].p_shouldPayMoney;
					}
					//商品
					if(result.ordertype==2){
						result.studentInfo.orderNo=primarydata.receiptNo;
					}
					//学员信息
					
					//表格数据

					//其他信息
					result.otherInfo.orderNo=entityObj.orderSigupId;
					result.otherInfo.mark=primarydata.remark;
					// if(this.ordertype==4){
						result.otherInfo.auditorTime=(entityObj.auditorTime||"");
						result.otherInfo.auditorUserName=entityObj.auditorUserName;
						result.otherInfo.auditorRemark=entityObj.auditorRemark||'订单取消';
					// }
				}
				else if(type===2){
					//学员信息
					
					//退费进度数据
					let shouldRefund=0,realRefund=entityObj.relMoney;
					combineData.forEach(row=>{
						shouldRefund=fNumber.add(shouldRefund,row.p_shouldRefundMoney);
					});
					result.progressInfo={
						//发起退费
						step1:{
							time:entityObj.createTime||'---',
							name:entityObj.createUserName||'---'
						},
						//审核
						step2:{
							time:entityObj.auditorTime||'---',
							name:entityObj.auditorUserName||'---',
							money:shouldRefund!=realRefund?realRefund:null
						},
						//退费
						step3:{
							time:entityObj.refundTime||'---',
							name:entityObj.refundUserName||'---'
						},
					};
					//表格数据
					result.tableStatistics.realMoney=entityObj.relMoney;
					result.tableStatistics.totalMoney=shouldRefund;

					//其他信息
					result.otherInfo.mark=primarydata.refundRemark;
					result.otherInfo.orderNo=entityObj.orderRefundId;
					result.otherInfo.statu=tool.getDictNameByValue(entityObj.orderRefundState,'order_refund_state');
					result.otherInfo.refundModeName=refundModeName2;
				}
				return result;
			},
			/**隐藏收退费详情（审核）弹窗 */
			hideChargesPopup(){
				this.chargeDetailsPopup.visible=false;
				this.refundDetailsPopup.visible=false;
			},
			/**重选支付方式-即详情页 */
			reselectPayMode(data){
				data.selectPayMode=true;
				data.isPaysuceess=false;
				this.moneyTableRowClick(data);
			},
			/**调起支付弹窗 */
			payTableRow(data){
				let primarydata=this._primaryTableData[data.index];
				
				let countList=[];
				let courselist=primarydata.signupCourseData||[];
				courselist.forEach(d=>{
					countList.push({type:'课程',name:d.className,money:d.courseMoney,primarydata:d});
				});
				let goodslist=primarydata.signupGoodsData||[];
				goodslist.forEach(d=>{
					countList.push({type:'商品',name:d.goodsName,money:d.realMoney,primarydata:d});
				});
				let mealslist=primarydata.signupMealsData||[];
				mealslist.forEach(d=>{
					countList.push({type:'餐费',name:d.mealsName,money:d.realMoney,primarydata:d});
				});
				
				vm.initPayInfo(countList,{
					orderSigupId:primarydata.orderSignupEntity.orderSigupId,
					realMoney:primarydata.orderSignupEntity.realMoney,
					payName:data.payMode==3?'wxpay':'alipay'
				});
				this._pay_suceess_index=data.index;
			},
			/**初始化二维码支付 */
			initPayInfo(countList,info){
				let goods_name = "";
				let goods_money = "";
				let payTitle = "";
				//从选择的班级、课程、商品中获取信息
				countList.forEach(item => {
					payTitle += payTitle == '' ? item.name : '、' + item.name;
					goods_name += goods_name == "" ? item.name : "," + item.name;
					goods_money += goods_money == "" ? item.money : "," + item.money;
				});
				let detail = {
					goods_name: goods_name,
					goods_num: goods_money,
					body: window.config.projectName + "- 支付"
				};
				//支付参数
				let payInfo ={
					orderParas:{
						outTradeNo: info.orderSigupId, //商户订单号
						totalFee: info.realMoney * 100,//支付金额(分)
						body: window.config.projectName + "- 支付", //显示在支付界面的标题
						tradeType: "NATIVE",//固定字段
						detail: JSON.stringify(detail),//订单详情
						campusId: this.$store.state.campusId//当前下单的校区ID
					},
					payTitle:payTitle,//支付标题
					payName:info.payName//支付方式名称
				};
				vm.$refs.payQRCode.init(payInfo);
			},
			/**支付成功 */
			suceessPay(){
				this.updateMoneyList();
				this.moneyTableRowClick({
					selectPayMode:false,
					primaryIndex:this._pay_suceess_index,
					isPaysuceess:true
				});
			},
			/**取消支付 */
			cancelPay(){},
			/**导出订单 */
			exportOrder(){
				//正在导出中
				if(vm.exportstate) {
					return;
				} else {
					vm.exportstate = true;
				}

				vm.exportNotification = vm.$notify({
					title: "订单导出处理中...",
					message: "请稍候，无须重复操作",
					iconClass: "el-icon-loading",
					duration: 0,
					showClose: false
				});
				api.orderManage_export(this.searchListParam).then(function(data){
					let blob = new Blob([data.data], {
						type: "application/vnd.ms-excel"
					});
					let filename = decodeURI(
						data.headers["content-disposition"].split(";")[1].split("=")[1]
					);
					let downloadElement = document.createElement("a");
					var href = window.URL.createObjectURL(blob);
					//创建下载的链接
					downloadElement.href = href;
					downloadElement.download = filename;
					//下载后文件名
					document.body.appendChild(downloadElement);
					downloadElement.click();
					//点击下载
					document.body.removeChild(downloadElement);
					//下载完成移除元素
					window.URL.revokeObjectURL(href);

					vm.exportstate = false;

					vm.exportNotification.close();

					vm.exportNotification = vm.$notify({
						type: "success",
						title: "订单导出成功",
						message: "请保存至本地",
						duration: 4000,
						showClose: false
					});
					//释放掉blob对象
					return data.data;
				}).catch(function(e) {
					vm.exportstate = false;
					vm.exportNotification.close();
					vm.exportNotification = vm.$notify({
						title: "",
						type: "error",
						message: "请求数据失败...",
						duration: 2000,
						showClose: false
					});
				});
			}
		},
		mounted(){
			vm=this;
			this.init();
		},
		computed:{
			
		},
		watch:{

		}
	}
</script>

<style lang="scss">
	.ordermanage-allorders{
		.content{
			margin:  0 auto;
			min-width: 15.48rem;
			width: 15.48rem;
			.tablebox{
				width: 15.48rem;
				margin-top: 0.2rem;
				padding: 0.2rem 0.32rem 0.2rem 0.32rem;
				height: auto;
				background: #fff;
				border: 0.01rem solid #ededed;
				border-radius: 0.10rem;
				box-shadow: 0 0.02rem 0.38rem 0 #3885f81f, 0 0 0.06rem 0 #3885f81f;
				.row{
					width: 100%;
				}
				.box-orderType{
					display: flex;
					margin: 0 0 0.1rem 0;
					.type{
						width: 1rem;
						height: 0.4rem;
						line-height: 0.4rem;
						text-align: center;
						margin-right: 0.3rem;
						cursor: pointer;
						user-select: none;
					}
					.type:hover{
						color: #3885f8;
					}
					.type.select{
						color: #3885f8;
						font-weight: bold;
						border-bottom: 0.02rem solid #3885f8;
					}
				}
				.headcontrolsbox{
					position: relative;
					width: 100%;
					height: 0.6rem;
					display: flex;
					align-items: center;
					.datepicker{
						background-color: #f7f8fa;
						border-radius: 0.08rem;
						font-size: 0.16rem;
						color: #666666;
						height: 0.36rem !important;
						line-height: 0.36rem !important;
						.el-range-input{
							background-color: #f7f8fa;
						}
					}
					.left{
						width: 50%;
					}
					.right{
						width: 50%;
						text-align: right;
					}
				}
				.bottomControlsBox{
					width: 100%;
					height: 0.5rem;
					display: flex;
    				align-items: flex-end;
					.el-pagination{
						float: left;
						width: 50%;
						text-align: right;
						// margin-top: 0.14rem;
					}
					.totalBox{
						float: left;
						width: 50%;
						.txt{
							font-size: 0.2rem;
							font-weight: 500;
							color: #666666;
						}
						.unit{
							font-size: 0.3rem;
							font-weight: 600;
							color: rgb(252,115,0)
						}
						.number{
							font-size: 0.3rem;
							font-weight: 600;
							color: rgb(252,115,0)
						}
					}
				}
				
			}
			.chargespopup{
				.el-dialog{
					width: 14rem !important;
					background-color: white !important;
					border-radius: 0.1rem !important;
					.el-dialog__header{
						.el-dialog__title{
							font-size: 0.22rem !important;
							color: #333333 !important;
							padding: 0rem 0.1rem 0rem 0.1rem;
							font-weight: bold;
						}
					}
					.el-dialog__body{
						font-size: 0.16rem !important;
						color: #666666 !important;
						padding: 0.2rem 0.3rem  !important;
					}
				}
			}
		}
		
		.paySuccess{
			.el-dialog{
				width: 13.5rem;
			}
		}
		//鼠标悬浮
		.hoverpointer:hover{
			cursor: pointer;
		}
		// 滚动条
		.scrollbarstyle::-webkit-scrollbar {
			width: 0.05rem;
		}
		.scrollbarstyle::-webkit-scrollbar-thumb {
			border-radius: 0.5rem;
			background: #BBBBBB;
		}
		.scrollbarstyle::-webkit-scrollbar-track {
			background: #F2F6FC;
		}
		.el-table__body-wrapper::-webkit-scrollbar {
			width: 0.05rem;
		}
		.el-table__body-wrapper::-webkit-scrollbar-thumb {
			border-radius: 0.5rem;
			background: #BBBBBB;
		}
		.el-table__body-wrapper::-webkit-scrollbar-track {
			background: #F2F6FC;
		}
	}
	// 搜索框样式
	.comSearchInput .el-input__inner {
		background-color: #f7f8fa;
		border-radius: 0.08rem;
		font-size: 0.16rem;
		color: #666666;
		height: 0.36rem !important;
		line-height: 0.36rem !important;
	}
</style>
<style scoped src="@/style/module/table.css"></style>
<style lang="scss">
	.ordermanage-allorders{
		.orderTypeSymbol{
			display: block;
			height: 0.26rem;
			line-height: 0.26rem;
			font-size: 0.16rem;
			border-radius: 0.04rem;
			width: 0.36rem;
			// padding: 0 0.05rem;
			text-align: center;
			cursor:pointer;
			user-select: none;
			// font-family: 'MicrosoftYaHei-Bold';
			font-weight: bold;
			font-stretch: normal;
			letter-spacing: 0px;
		}
		// 课
		.orderTypeSymbol[type='1']{
			background-color: #daf1ff;
			color: #1f76f7;
		}
		//商
		.orderTypeSymbol[type='2']{
			background-color: #edefff;
			color: #487ef9;
		}
		//订
		.orderTypeSymbol[type='3']{
			background-color: #e8f3dc;
			color: #87c143;
		}
		//餐
		.orderTypeSymbol[type='4']{
			background-color: #ffe9e9;
			color: #fa7777;
		}
		.coverTable{
			td{
				white-space: pre-line !important;
			}
		}
		.tbody{
			tr{
				background-color: white !important;
			}
			tr[rowIndex='odd']{
				background-color: #f7f9fc !important;
			}
			tr[rowhover='1']{
				background-color: #e4efff !important;
			}
		}
	}
</style>
